package org.hertsig.magiccardmarket;

import lombok.AccessLevel;
import lombok.Getter;

import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClientBuilder;

class UrlParamAuthApi extends MagicCardMarketApi {
	private String userName;
	private String apiKey;
	@Getter(AccessLevel.PROTECTED) private final HttpClient client;
	
	public UrlParamAuthApi(String userName, String apiKey) {
		this.userName = userName;
		this.apiKey = apiKey;
		this.client = HttpClientBuilder.create()
			.setSSLSocketFactory(new SSLConnectionSocketFactory(createSslContext()))
			.build();
	}
	
	@Override
	protected String base() {
		return BASE_URL + escape(userName) + "/" + escape(apiKey) + "/";
	}
}
